<template>
  <p-table
    class="table-list-container"
    row-key="id"
    :columns="columns"
    bordered
    v-bind="$attrs"
    v-on="$listeners"
  >
    <a
      slot="clueNumber"
      slot-scope="text, record"
      @click="$emit('number-click', record)"
    >
      {{ text }}
    </a>
  </p-table>
</template>

<script>
export default {
  data() {
    return {};
  },
  computed: {
    stateOptions() {
      return this.$store.state.dictionary.dict['leads_status'] || {};
    },
    orgOptions() {
      return this.$store.getters.getOrg({
        code: 'ltcsmsizebu',
      });
    },
    transferOption() {
      return this.$store.state.dictionary.dict['leads_transfer_status'] || {};
    },
    businessOption() {
      return this.$store.state.dictionary.dict['leads_trans_biz_status'] || {};
    },
    columns() {
      const columns = [
        {
          align: 'center',
          title: '序号',
          width: 60,
          customRender(t, r, index) {
            return parseInt(index) + 1;
          },
        },
        {
          align: 'center',
          title: '线索编号',
          dataIndex: 'leadsNo',
          width: 150,
          sorter: true,
          scopedSlots: { customRender: 'clueNumber' },
        },
        {
          align: 'center',
          title: '线索名称',
          dataIndex: 'leadsName',
          width: 200,
          ellipsis: true,
          sorter: true,
        },
        {
          align: 'center',
          title: '客户简称',
          dataIndex: 'customerShortName',
          width: 100,
          sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: '线索状态',
          dataIndex: 'leadsStatus',
          width: 100,
          sorter: true,
          ellipsis: true,
          customRender: text => this.stateOptions[text],
        },
        {
          align: 'center',
          title: '转派状态',
          dataIndex: 'transferStatus',
          width: 100,
          sorter: true,
          ellipsis: true,
          customRender: text => this.transferOption[text],
        },
        {
          align: 'center',
          title: '转商机审批状态',
          dataIndex: 'businessAuditStatus',
          width: 100,
          sorter: true,
          ellipsis: true,
          customRender: text => this.businessOption[text],
        },
        {
          align: 'center',
          title: '销售组织',
          dataIndex: 'salesOrgCode',
          width: 100,
          sorter: true,
          ellipsis: true,
          customRender: text => this.orgOptions[text],
        },
        {
          align: 'center',
          title: '销售',
          dataIndex: 'salesName',
          width: 100,
          sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: 'PM',
          dataIndex: 'pmName',
          width: 100,
          sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: '创建人',
          dataIndex: 'createUserName',
          width: 100,
          sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: '创建时间',
          dataIndex: 'createTime',
          width: 200,
          sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: '最后修改人',
          dataIndex: 'updateUserName',
          width: 100,
          sorter: true,
          ellipsis: true,
        },
        {
          align: 'center',
          title: '最后修改时间',
          dataIndex: 'updateTime',
          width: 200,
          sorter: true,
          ellipsis: true,
        },
      ];
      return columns;
    },
  },
  created() {},
  methods: {},
};
</script>

<style lang="less" scoped>
.table-list-container {
  margin-top: 20px;
}
</style>
